package com.yellowpage.wf.service;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;
import com.yellowpage.wf.dao.NodeAttachmentDao;
import com.yellowpage.wf.data.Attachment;
import com.yellowpage.wf.data.NodeAttachment;

public class NodeAttachmentServiceImpl extends BaseServiceImpl implements NodeAttachmentService {
	  private NodeAttachmentDao nodeAttachmentDao;
	
	  public void setNodeAttachmentDao(NodeAttachmentDao nodeAttachmentDao) {
		  this.nodeAttachmentDao = nodeAttachmentDao;
	  }
	
	
	  /* White generate Method */ 
	  public NodeAttachment getNodeAttachment(Long id) {
			return nodeAttachmentDao.get(id);
		}
	  public void saveNodeAttachment(NodeAttachment nodeAttachment)
	  {
		  nodeAttachmentDao.save(nodeAttachment);
	  }
	  public void updateNodeAttachment(NodeAttachment nodeAttachment){
		  nodeAttachmentDao.update(nodeAttachment);
	  }
	  public void delete(List deleteList){
		  nodeAttachmentDao.remove(deleteList);
	  }
	  
	  public List<Map> getNodeAttachmentOfNode(Long workflowNodeId)
	  {
		  String sql = "select wna.node_attachment_id,wna.name,wna.type,wna.workflow_node_id,wna.resource_id,wna.description, " +
	  		" wna.create_user,wna.create_time,(select wre.name from wf_resource wre where wre.resource_id = wna.resource_id) as fname " +
	  		" from wf_node_attachment wna " +
	  		" where wna.workflow_node_id =" + workflowNodeId.toString();

	  	QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(sql);
	  	List<Map> resultList = this.baseDao.query(sqlAssistant, new HashMap());
	  	return resultList;
	  }
}	